﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace ciiattack
{
    public class Missile : Actor
    {
        Boolean isActive;
        Boolean isToutch = false;

        public Boolean IsToutch
        {
            get { return isToutch; }
            set { isToutch = value; }
        }

        public Boolean IsActive
        {
            get { return isActive; }
        }

        public Missile(Texture2D texture, Vector2 origin, SpriteBatch spriteBatch, EnemyManager enemyManager)
            : base(texture, origin, spriteBatch, Vector2.Zero)
        {
            isActive = false;
        }

        public override void Update(GameTime gameTime)
        {
            if (this.Position.Y > -32.0f)
            {
                this.Position += Vector2.UnitY * -4.0f;
            }
            else
            {
                this.isActive = false;
            }

            base.Update(gameTime);
        }

        public void Fire(Vector2 position)
        {
            this.Position = position;
            this.isActive = true;
        }

        public void OnHit()
        {
            this.reset(); // reset()
        }

        private void reset()
        {
            Random random = new Random(); // Create a new Random instance

            this.Position = new Vector2(32.0f + random.Next(176), -32.0f - random.Next(256)); // Move back to the top of the screen
        }
    }
}